<div class="blogs index js-response">
<ul class="filter-list-block clearfix">
        <li <?php if (!empty($this->request->params['named']['filter_id']) && $this->request->params['named']['filter_id'] ==  ConstMoreAction::Active) { echo 'class="active"';} ?>><span class="green-block" title="<?php echo __l('Published'); ?>"><?php echo $this->Html->link($this->Html->cInt($published_blogs,false).'<span>' .__l('Published'). '</span>', array('controller'=>'blogs','action'=>'index','filter_id' => ConstMoreAction::Active), array('escape' => false));?></span> </li>
        <li <?php if (!empty($this->request->params['named']['filter_id']) && $this->request->params['named']['filter_id'] ==  ConstMoreAction::Suspend) { echo 'class="active"';} ?>><span class="red-block" title="<?php echo __l('Suspended'); ?>"><?php echo $this->Html->link($this->Html->cInt($suspended,false).'<span>' .__l('Suspended'). '</span>', array('controller'=>'blogs','action'=>'index','filter_id' => ConstMoreAction::Suspend), array('escape' => false));?></span> </li>
        <li <?php if (!empty($this->request->params['named']['filter_id']) && $this->request->params['named']['filter_id'] ==  ConstMoreAction::Flagged) { echo 'class="active"';} ?>><span class="purple-block" title="<?php echo __l('Flagged'); ?>"><?php echo $this->Html->link($this->Html->cInt($system_flagged,false).'<span>' .__l('Flagged'). '</span>', array('controller'=>'blogs','action'=>'index','filter_id' => ConstMoreAction::Flagged), array('escape' => false));?></span> </li>
</ul>

<div class="page-count-block clearfix">
	    <div class="grid_left">
	      <?php echo $this->element('paging_counter'); ?>
		</div>
		<div class="grid_left">
            <?php echo $this->Form->create('Blog', array('type' => 'get', 'class' => 'normal search-form clearfix', 'action'=>'index')); ?>
                        <?php echo $this->Form->input('q', array('label' => __l('Keyword'))); ?>
                		<?php echo $this->Form->submit(__l('Search'));?>
            <?php echo $this->Form->end(); ?>
		</div>
        <div class="add-block grid_right">
     	<?php echo $this->Html->link(__l('Add'), array('controller' => 'blogs', 'action' => 'add'), array('class' => 'add', 'title'=>__l('Add'))); ?>
       </div>
 </div>

<?php
    echo $this->Form->create('Blog' , array('class' => 'normal','action' => 'update'));
    echo $this->Form->input('r', array('type' => 'hidden', 'value' => $this->request->url));
?>
<table class="list">
	<tr>
        <th class="select"><?php echo __l('Select'); ?></th>
		<th class="actions"><?php echo __l('Actions'); ?></th>
		<th class="dl"><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Project'),'Project.name');?></div></th>
		<th class="dl"><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Update'), 'title');?></div></th>
		<th class="dl"><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Author'), 'User.username');?></div></th>
        <?php if (Configure::read('Project.is_project_update_comment_enabled')) : ?>
		<th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Comments'), 'blog_comment_count');?></div></th>
        <?php endif; ?>
		<th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Created'), 'created');?></div></th>
		<th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Published?'), 'is_published');?></div></th>
	</tr>
<?php
if (!empty($blogs)):

$i = 0;
foreach ($blogs as $blog):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
	if($blog['Blog']['is_published']):
		$status_class = 'js-checkbox-active';
	else:
		$status_class = 'js-checkbox-inactive';
	endif;
	if($blog['Blog']['admin_suspend']):
		$status_class.= ' js-checkbox-suspended';
	else:
		$status_class.= ' js-checkbox-unsuspended';
	endif;
	if($blog['Blog']['is_system_flagged']):
		$status_class.= ' js-checkbox-flagged';
	else:
		$status_class.= ' js-checkbox-unflagged';
	endif;
?>
	<tr<?php echo $class;?>>
        <td class="select"><?php echo $this->Form->input('Blog.'.$blog['Blog']['id'].'.id', array('type' => 'checkbox', 'id' => "admin_checkbox_".$blog['Blog']['id'], 'label' => false, 'class' => $status_class.' js-checkbox-list')); ?></td>
		<td class="actions dl">
            <div class="action-block">
                <span class="action-information-block">
                    <span class="action-left-block">&nbsp;&nbsp;</span>
                        <span class="action-center-block">
                            <span class="action-info">
                                <?php echo __l('Action');?>
                             </span>
                        </span>
                    </span>
                    <div class="action-inner-block">
                    <div class="action-inner-left-block">
                        <ul class="action-link clearfix">
		<li><?php echo $this->Html->link(__l('Edit'), array('action'=>'edit', $blog['Blog']['id']), array('class' => 'edit js-edit', 'title' => __l('Edit')));?></li>
		<li><?php echo $this->Html->link(__l('Delete'), array('action'=>'delete', $blog['Blog']['id']), array('class' => 'delete js-delete', 'title' => __l('Delete'))); ?></li>
		    <?php if($blog['Blog']['is_system_flagged']):?>
            <li>	<?php echo $this->Html->link(__l('Clear flag'), array('action' => 'admin_update_stats', $blog['Blog']['id'], 'flag' => 'deactivate'), array('class' => 'clear-flag js-delete', 'title' => __l('Clear flag')));?>
            </li>
        <?php else:?>
            <li>	<?php echo $this->Html->link(__l('Flag'), array('action' => 'admin_update_stats', $blog['Blog']['id'], 'flag' => 'active'), array('class' => 'flag js-delete', 'title' => __l('Flag')));?>
            </li>
        <?php endif;?>
        <?php if($blog['Blog']['admin_suspend']):?>
			<li><?php echo $this->Html->link(__l('Unsuspend'), array('action' => 'admin_update_stats', $blog['Blog']['id'], 'flag' => 'unsuspend'), array('class' => 'unsuspend js-delete', 'title' => __l('Unsuspend')));?>
			</li>
		<?php else:?>
			<li><?php echo $this->Html->link(__l('Suspend'), array('action' => 'admin_update_stats', $blog['Blog']['id'], 'flag' => 'suspend'), array('class' => 'suspend js-delete', 'title' => __l('Suspend')));?>
			</li>
		<?php endif;?>
                   		 </ul>
    					</div>
    					<div class="action-bottom-block"></div>
    				  </div>
              </div>
        </td>
        
        <td class="dl">
                      <div class="clearfix">
                      <?PHP
                         if($is_wallet_enabled)
                         {
                            $project_status = $blog['Project']['ProjectStatus']['name'];
                         }
                           else
                           {
                             $project_status = str_replace("Refunded","Voided",$blog['Project']['ProjectStatus']['name']);
                           }
                        ?>
                         <span title="<?php echo $this->Html->cText($project_status,false); ?>" class="project-atatus-info project-status-<?php echo $blog['Project']['project_status_id'];?>">
						 <?php echo $this->Html->cText($blog['Project']['ProjectStatus']['name']); ?>
                         </span>
		<?php echo $this->Html->link($this->Html->cText($this->Html->truncate($blog['Project']['name'],90, array('ending' => '...'))), array('controller' => 'projects', 'action' => 'view', $blog['Project']['slug'], 'admin' => false), array('escape' => false,'title'=>$this->Html->cText($blog['Project']['name'],false)));?>
                        </div>
        </td>
        <td class="dl">
        <div class="clearfix">
		  <span class="js-truncate {size:50}">
		      <?php echo $this->Html->link($this->Html->cText($blog['Blog']['title']), array('controller' => 'blogs', 'action' => 'view', $blog['Blog']['slug'], 'admin' => false), array('escape' => false,'title'=>$this->Html->cText($blog['Blog']['title'],false)));?>
		  </span>
        <?php
				if($blog['Blog']['admin_suspend']):
					echo '<span class="backeder round-3">'.__l('Admin Suspended').'</span>';
				endif;
		   		if($blog['Blog']['is_system_flagged']):
					echo '<span class="flaggedfil">'.__l('System Flagged').'</span>';
				endif;
				if(!empty($blog['Blog']['project_flag_count'])) :
					echo '<span class="active">'.__l('User Flagged').'</span>';
				endif;
				if($blog['Blog']['is_published']) :
					echo '<span class="pub-update round-3">'.__l('Published').'</span>';
				endif;				
			?>
		</div>
</td>
        <td class="dl"><?php echo $this->Html->link($this->Html->cText($blog['User']['username']), array('controller'=> 'users', 'action' => 'view', $blog['User']['username'], 'admin' => false), array('escape' => false,'title'=>$this->Html->cText($blog['User']['username'],false)));?></td>
        <?php if (Configure::read('Project.is_project_update_comment_enabled')) : ?>
        <td><?php echo $this->Html->link($this->Html->cInt($blog['Blog']['blog_comment_count']), array('controller' => 'blog_comments', 'action' => 'index', 'blog' => $blog['Blog']['id']), array('escape' => false));?></td>
        <?php endif; ?>
		<td><?php echo $this->Html->cDateTimeHighlight($blog['Blog']['modified']);?></td>
		<?PHP
		  if($blog['Blog']['is_published']):			
			$td_class = 'admin-status-1';
		 else:			
			$td_class = 'admin-status-0';
		endif;
		?>
		<td class="<?PHP echo $td_class; ?>"><?php echo $this->Html->cBool($blog['Blog']['is_published']);?></td>
	</tr>
<?php
    endforeach;
else:
?>
	<tr>
		<td class="notice" colspan="9"><?php echo __l('No updates available');?></td>
	</tr>
<?php
endif;
?>
</table>

<?php
if (!empty($blogs)):
    ?>
	<div class="clearfix">
	<div class="admin-select-block grid_left">
		<?php echo __l('Select:'); ?>
		<?php echo $this->Html->link(__l('All'), '#', array('class' => 'js-admin-select-all', 'title' => __l('All'))); ?>
		<?php echo $this->Html->link(__l('None'), '#', array('class' => 'js-admin-select-none', 'title' => __l('None'))); ?>
		<?php echo $this->Html->link(__l('Inactive'), '#', array('class' => 'js-admin-select-pending', 'title' => __l('Inactive'))); ?>
		<?php echo $this->Html->link(__l('Active'), '#', array('class' => 'js-admin-select-approved', 'title' => __l('Active'))); ?>
		<?php echo $this->Html->link(__l('Suspended'), '#', array('class' => 'js-admin-select-suspended', 'title' => __l('Suspended'))); ?>
		<?php echo $this->Html->link(__l('Flagged'), '#', array('class' => 'js-admin-select-flagged', 'title' => __l('Flagged'))); ?>
	</div>
	
	<div class="admin-checkbox-button grid_4 grid_left"><?php echo $this->Form->input('more_action_id', array('class' => 'js-admin-index-autosubmit', 'label' => false, 'empty' => __l('-- More actions --'))); ?></div>
	<div class="js-pagination grid_right">
        <?php echo $this->element('paging_links'); ?>
    </div>
	</div>
    <div class="hide">
	    <?php echo $this->Form->submit('Submit'); ?>
    </div>
    <?php
endif;
echo $this->Form->end();
?>
</div>